@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />

    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script type="text/javascript" src="//code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
    <link href="{{url('js/lib/jquery-ui-timepicker-addon.css')}}" type="text/css" />
    <script src="{{url('js/lib/jquery-ui-timepicker-addon.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery.ui.datepicker-zh-CN.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery-ui-timepicker-zh-CN.js')}}" type="text/javascript"></script>
    <style>
        .sx{padding: 10px}
        .sx-btn{width: 64px;height: 30px;background-color: #4dbcd3;color: #fff;border: #4dbcd3;border-radius: 7%;}
    </style>
@endsection

@section('html-body')
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">游戏排名列表</a>
            <em></em>
        </div>
{{--
        @include('admin.common.goods-header')
--}}

        {{--<div class="filter-box clearfix">--}}
            {{--<div class="fl" style="display: inline-flex">--}}
                {{--<div class="sx">--}}
                    {{--<span>选择时间：</span>--}}
                    {{--<input class="gg-ipt" style="width: 130px;height: 26px" type="text" placeholder="开始时间" name="start_time" id="start_time" value="{{$startTime}}" />---}}
                    {{--<input class="gg-ipt" style="width: 130px;height: 26px" type="text" placeholder="结束时间" name="end_time" id="end_time" value="{{$endTime}}" />--}}
                {{--</div>--}}
                {{--<div class="sx">--}}
                    {{--<button class="sx-btn" id="sx_btn">筛选</button>--}}
                {{--</div>--}}
            {{--</div>--}}
        {{--</div>--}}


        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>游戏排名</th>
                    <th>用户id</th>
                    <th>用户手机</th>
                    <th>用户头像</th>
                    <th>用户昵称</th>
                    <th>剩余积分</th>
                    <th>金条数量</th>
                    <th>已兑换积分</th>
                    <th>统计时间</th>
                </tr>
                </thead>
                <tbody>
                @if(count($allUserScores)>0)
                    @foreach($allUserScores as $key=>$allUserScore)
                        <tr id="">
                            <td>{{($key+1) * $page}}</td>
                            <td>{{!is_null($allUserScore->user) ? $allUserScore->user->id:"-"}}</td>
                            <td>{{!is_null($allUserScore->user) ? $allUserScore->user->phone:"-"}}</td>
                            <td class="account-td" style="width: 20px;">
                                <span class="photo">
                                    <img src="{{$allUserScore->user->user_info->photo_url}}" alt="">
                                </span>
                            </td>
                            <td>{{$allUserScore->user->user_info->nickname}}</td>
                            <td>{{$allUserScore->score}}</td>
                            <td>{{$allUserScore->gold_num}}</td>
                            <td>{{$allUserScore->exchange_score}}</td>
                            <td>{{date('Y-m-d H:i:s',time())}}</td>

                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
            <?php echo $allUserScores->render(); ?>
        </div>

    </div>
    <script>
        $(function(){


            jQuery('#start_time').datetimepicker({
                timeFormat: "HH:mm:ss",
                dateFormat: "yy-mm-dd",
                beforeShow: function () {
                    setTimeout(
                        function () {
                            $('#ui-datepicker-div').css("z-index", 1000);
                        }, 100
                    );
                }
            });

            jQuery('#end_time').datetimepicker({
                timeFormat: "HH:mm:ss",
                dateFormat: "yy-mm-dd",
                beforeShow: function () {
                    setTimeout(
                        function () {
                            $('#ui-datepicker-div').css("z-index", 1000);
                        }, 100
                    );
                }
            });

            $('#sx_btn').click(function(){
/*
                var orderNum  = $('#order_num').val();
*/
                var startTime = $('#start_time').val();
                var endTime   = $('#end_time').val();

                window.location.href = "{{route('Admin.Home.gameRank')}}?start_time="+startTime+"&end_time="+endTime;
            });

            $(document).on("click",".del",function(){
                var id = $(this).attr("data-id");

                noty({
                    text: '你确定要删除吗?',
                    buttons: [
                        {addClass: 'btn btn-primary', text: '确定', onClick: function($noty) {
                                $noty.close();
                                $.ajax({
                                    url:'{{route('Api.Admin.goods.delGoods')}}',
                                    type:'post',
                                    dataType:'json',
                                    data:{id:id},
                                    success:function(obj){
                                        if(obj.level == "success"){
                                            $("#goods_"+id).hide('slow');
                                        }else{
                                            noty({type:obj.level,text:obj.message,timeout:600});
                                        }
                                    },
                                    error:function(obj){
                                        console.log(obj);
                                    }

                                });
                            }
                        },
                        {addClass: 'btn btn-danger', text: '取消', onClick: function($noty) {
                                $noty.close();
                            }
                        }
                    ]
                });

            });
        });
    </script>
@endsection